//
//  StringUtil.h
//  Tank For IPhone
//
//  Created by 奕 朱 on 11-3-9.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface StringUtil : NSObject

+ (NSMutableArray *) splitStr: (NSString *) str cellSize: (int) cellSize; 

@end

@implementation StringUtil

+ (NSMutableArray *) splitStr: (NSString *) str cellSize: (int) cellSize {
	
	NSUInteger _strsLength = [str length] * 1.0 / cellSize;
	
	NSMutableArray * _strs = [[NSMutableArray alloc] initWithCapacity: _strsLength];
	 
	NSUInteger _startIndex = 0;
	for (int i = 0; i < [str length]; i++) {
		NSString *__str = [str substringWithRange: 
						   NSMakeRange(_startIndex, 1)];
		[_strs insertObject: __str atIndex: i];
		[__str release];
		_startIndex =  _startIndex + cellSize > [str length] ? [str length] : _startIndex + cellSize;
	} 
	
	return _strs;
}

@end
